|
|
|
An example shown
here is a simple function to add up all of the integers in a single
dimensioned array.
|
|
A structure type
is usually defined near to the start of a file using the typedef statement.
typedef defines and names a new type, allowing its use throughout the
program. typedefs usually occur just after the #define and #include
statements in a file.
|
|
Here is an
example structure definition.
|
|
typedef struct
{
|
|
char name[64];
|
|
char course[128];
|
|
int
age;
|
|
int
year_of_study;
|
|
} student;
|
|
This defines a
new type student which can be used to declare variables as follows.
|
|
student st_rec;
|
|
This creates a
variable called st_rec of type student. The variable has members called name,
course, age and year_of_study.
|